<!--
 * @Description: 泵送难度模型
 * @Author: wangwangwang
 * @Date: 2020-09-21 14:09:06
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-12-29 15:08:05
-->
<template>
  <div class="pages_content table PMDM">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>
      <el-main>
        <div class="info">
          <!-- 泵送标号： -->
          <div>
            <div>
              公司：
              <el-select v-model="companyId" placeholder="请选择" @change="changeCompany">
                <el-option v-for="item in companylist" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </div>
            <div class="title">
              <h3>泵送标号：</h3>
              <el-button size="small" class="bottom_all" style="margin-left: 0" @click="open(1)">
                <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
                添加
              </el-button>
            </div>
            <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="allData['1']" tooltip-effect="dark">
              <el-table-column label="标号" align="center">
                <template slot-scope="scope">
                  <el-select v-model="scope.row.showarr" multiple style="width:100%l;max-width:300px" placeholder="请选择" @change="change1(scope.row,scope.$index)">
                    <el-option v-for="(item, index) in list" :key="index" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column label="基准难度系数" align="center">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.difficultyCoefficient" style="width:100%;max-width:300px" placeholder="请输入" onblur="if(value > 10 ){ value = 10} else if(value<1){value = 1}" onkeypress='return( /\d|\./.test(String.fromCharCode(event.keyCode)))' @change="change1(scope.row,scope.$index)" @input="scope.row.difficultyCoefficient=$regExp.checkNum(scope.row.difficultyCoefficient)" @blur="scope.row.difficultyCoefficient=$regExp.blurCheckNum(scope.row.difficultyCoefficient)">
                  </el-input>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="left" width="220">
                <template slot-scope="a">
                  <el-button size="mini" class="bottom_two" @click="delItem1(a.row,a.$index)">
                    <i class="icon iconfont iconicon_button_delete" style="font-size: 12px"></i>
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 垂直高度： -->
          <div>
            <div class="title">
              <h3>垂直高度：</h3>
              <div>
                <el-button size="small" class="bottom_all" style="margin-left: 0" @click="open(2)">
                  <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
                  添加
                </el-button>
              </div>
            </div>
            <el-table :header-cell-style="{ background: '#f3f6f9' }" border style="width: 100%" :data="allData['2']" tooltip-effect="dark">
              <el-table-column label="垂直高度" align="center">
                <template slot-scope="scope">
                  <div v-if="scope.$index==0" class="itemdiv">
                    <span style="padding:20px">小于</span>
                    <el-input v-model="scope.row.lengthTop" type="Number" style="width:270px" @change="change2(2)">
                      <template slot="append">米</template>
                    </el-input>
                  </div>
                  <div v-else-if="scope.$index==(allData['2'].length-1)" class="itemdiv">
                    <span style="padding:20px">大于</span>
                    {{scope.row.lengthTop=allData['2'][scope.$index-1].lengthTop}}
                  </div>
                  <div v-else class="itemdiv">
                    <el-input v-model="allData['2'][scope.$index-1].lengthTop" disabled style="width:140px">
                      <template slot="append">米</template>
                    </el-input>
                    <span style="padding:20px">至</span>
                    <el-input v-model="scope.row.lengthTop" type="Number" style="width:140px" @change="scope.row.lengthTop<allData['2'][scope.$index-1].lengthTop?scope.row.lengthTop=allData['2'][scope.$index-1].lengthTop:'',change2(2)">
                      <template slot="append">米</template>
                    </el-input>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="基准难度系数" align="center">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.difficultyCoefficient" type="Number" style="width:100%;max-width:300px" onblur="if(value > 10 ){ value = 10} else if(value<1){value = 1}" onkeypress='return( /\d|\./.test(String.fromCharCode(event.keyCode)))' @change="change(scope.row,scope.$index)" @input="scope.row.difficultyCoefficient=$regExp.checkNum(scope.row.difficultyCoefficient)" @blur="scope.row.difficultyCoefficient=$regExp.blurCheckNum(scope.row.difficultyCoefficient)">
                  </el-input>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="left" width="220">
                <template slot-scope="scope">
                  <div v-if="scope.$index!==0&&scope.$index!==(allData['2'].length-1)">
                    <el-button class="bottom_two" size="mini" @click="delitem2(scope.row,scope.$index,2)">
                      <i class="icon iconfont iconicon_button_delete" style="font-size: 12px"></i>
                      删除
                    </el-button>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 垂直基坑深度： -->
          <div>
            <div class="title">
              <h3>垂直基坑深度：</h3>
              <div>
                <el-button size="small" class="bottom_all" style="margin-left: 0" @click="open(3)">
                  <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
                  添加
                </el-button>
              </div>
            </div>
            <el-table :header-cell-style="{ background: '#f3f6f9' }" border style="width: 100%" :data="allData['3']" tooltip-effect="dark">
              <el-table-column label="垂直基坑深度" align="center">
                <template slot-scope="scope">
                  <div v-if="scope.$index==0" class="itemdiv">
                    <span style="padding:20px">小于</span>
                    <el-input v-model="scope.row.lengthTop" type="Number" style="width:230px" @change="change2(3)">
                      <template slot="append">米</template>
                    </el-input>
                  </div>
                  <div v-else-if="scope.$index==(allData['3'].length-1)" class="itemdiv">
                    <span style="padding:20px">大于</span>
                    {{scope.row.lengthTop=allData['3'][scope.$index-1].lengthTop}}
                  </div>
                  <div v-else class="itemdiv">
                    <el-input v-model="allData['3'][scope.$index-1].lengthTop" disabled style="width:120px">
                      <template slot="append">米</template>
                    </el-input>
                    <span style="padding:20px">至</span>
                    <el-input v-model="scope.row.lengthTop" type="Number" style="width:120px" @change="scope.row.lengthTop<allData['3'][scope.$index-1].lengthTop?scope.row.lengthTop=allData['3'][scope.$index-1].lengthTop:'',change2(3)">
                      <template slot="append">米</template>
                    </el-input>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="基准难度系数" align="center">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.difficultyCoefficient" type="number" style="width:100%;max-width:300px" @change="change(scope.row)">
                  </el-input>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="left" width="220">
                <template slot-scope="scope">
                  <div v-if="scope.$index!==0&&scope.$index!==(allData['3'].length-1)">
                    <el-button class="bottom_two" size="mini" @click="delitem2(scope.row,scope.$index,3)">
                      <i class="icon iconfont iconicon_button_delete" style="font-size: 12px"></i>
                      删除
                    </el-button>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 下水平管与立管倾斜角度： -->
          <div>
            <div class="title">
              <h3>下水平管与立管倾斜角度：</h3>
            </div>
            <div class="table">
              <el-table :header-cell-style="{ background: '#f3f6f9' }" border style="width: 100%" :data="allData['4']" tooltip-effect="dark">
                <el-table-column label="角度" align="center" prop="name"></el-table-column>
                <el-table-column label="基准难度系数" align="center">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.difficultyCoefficient" type="Number" placeholder="请输入" onblur="if(value > 10 ){ value = 10} else if(value<1){value = 1}" onkeypress='return( /\d|\./.test(String.fromCharCode(event.keyCode)))' @change="change(scope.row)" @input="scope.row.difficultyCoefficient=$regExp.checkNum(scope.row.difficultyCoefficient)" @blur="scope.row.difficultyCoefficient=$regExp.blurCheckNum(scope.row.difficultyCoefficient)" />
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <!-- 超长水平管水平弯头数量 -->
          <div>
            <div class="title">
              <h3>超长水平管水平弯头数量</h3>
              <div>
                <el-button size="small" class="bottom_all" style="margin-left: 0" @click="open(5)">
                  <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
                  添加
                </el-button>
              </div>
            </div>
            <el-table :header-cell-style="{ background: '#f3f6f9' }" border style="width: 100%" :data="allData['5']" tooltip-effect="dark">
              <el-table-column label="水平泵管长度范围" align="center" width="320">
                <template slot-scope="scope">
                  <div v-if="scope.$index==0" class="itemdiv">
                    <span style="padding:20px">小于</span>
                    <el-input v-model="scope.row.lengthTop" type="Number" style="width:160px" @change="change2(5,'lengthTop')">
                      <template slot="append">米</template>
                    </el-input>
                  </div>
                  <div v-else-if="scope.$index==(allData['5'].length-1)" class="itemdiv">
                    <span style="padding:20px">大于</span>
                    {{scope.row.lengthTop=allData['5'][scope.$index-1].lengthTop}}
                  </div>
                  <div v-else class="itemdiv">
                    <el-input v-model="allData['5'][scope.$index-1].lengthTop" type="Number" disabled style="width:140px">
                      <template slot="append">米</template>
                    </el-input>
                    <span style="padding:20px">至</span>
                    <el-input v-model="scope.row.lengthTop" type="Number" style="width:140px" @change="scope.row.lengthTop<allData['5'][scope.$index-1].lengthTop?scope.row.lengthTop=allData['5'][scope.$index-1].lengthTop:'',change2(5,'lengthTop')">
                      <template slot="append">米</template>
                    </el-input>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="弯头数量" align="center" width="280">
                <template slot-scope="scope">
                  <div v-for="(item,index) in scope.row.list" :key="index" class="divdiv">
                    <div>
                      <div v-if="index==0" class="itemdiv1">
                        <span style="padding:20px">小于</span>
                        <el-input v-model="item.numTop" type="Number" style="width:160px" onkeypress='return( /\d/.test(String.fromCharCode(event.keyCode)))' @change="change2(5,'numTop')">
                        </el-input>
                      </div>
                      <div v-else-if="index==(scope.row.list.length-1)" class="itemdiv1">
                        <span style="padding:20px">大于</span>
                        {{item.numTop=scope.row.list[index-1].numTop}}
                      </div>
                      <div v-else class="itemdiv1">
                        <el-input v-model="scope.row.list[index-1].numTop" type="Number" disabled style="width:100px">
                        </el-input>
                        <span style="padding:20px">-</span>
                        <el-input v-model="item.numTop" type="Number" style="width:100px" @change="item.numTop<scope.row.list[index-1].numTop?item.numTop=scope.row.list[index-1].numTop:'',change2(5,'numTop')">
                        </el-input>
                      </div>
                    </div>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="left" width="220">
                <template slot-scope="scope">
                  <div v-for="(item,index) in scope.row.list" :key="index" class="divdiv">
                    <div>
                      <el-button v-if="index!==0&&index!==(scope.row.list.length-1)" class="bottom_two" size="mini" @click="delitem6(item,index,scope.row)">
                        <i class="icon iconfont iconicon_button_delete" style="font-size: 12px"></i>
                        删除
                      </el-button>
                      <el-button v-if="index==(scope.row.list.length-2)" size="mini" class="bottom_all" style="margin-left: 12px" @click="addItem6(scope.row)">
                        <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
                        添加
                      </el-button>
                    </div>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="基准难度系数" align="center" width="140">
                <template slot-scope="scope">
                  <div v-for="(item,index) in scope.row.list" :key="index" class="divdiv">
                    <div>
                      <el-input v-model="item.difficultyCoefficient" type="Number" style="width:100%" onblur="if(value > 10 ){ value = 10} else if(value<1){value = 1}" onkeypress='return( /\d|\./.test(String.fromCharCode(event.keyCode)))' @change="change(scope.row)" @input="scope.row.difficultyCoefficient=$regExp.checkNum(scope.row.difficultyCoefficient)" @blur="scope.row.difficultyCoefficient=$regExp.blurCheckNum(scope.row.difficultyCoefficient)">
                      </el-input>
                    </div>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="left" width="auto">
                <template slot-scope="scope">
                  <el-button v-if="scope.$index!==0&&scope.$index!==(allData['5'].length-1)" class="bottom_two" size="mini" @click="delitem2(scope.row,scope.$index,5)">
                    <i class="icon iconfont iconicon_button_delete" style="font-size: 12px"></i>
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import breaDcrumb from '@/components/breadcrumb';
import { getUserInfo } from "@/utils/auth";
import { getData, getList, saveOrUpdate } from '@/api/besSer/WMmanagement/PMDM.js'
import { Loading } from 'element-ui';
import { setTimeout } from 'timers';
import { permissionsCompanyList } from "@/api/common.js";
let loadingInstance
let companyName = '';
let companyId = '';
class addData {
  constructor(difficultyCoefficient, dataType) {
    this.company = companyName
    this.companyId = companyId
    this.status = 1
    this.difficultyCoefficient = (difficultyCoefficient||difficultyCoefficient===0) ? difficultyCoefficient : undefined
    this.dataType = dataType
  }
}
class Child1 extends addData {
  constructor(a, b, name, showarr, id) {
    super(a, b);
    this.name = name
    this.showarr = showarr || []
    this.id = id || ''
  }
}
class Child2 extends addData {
  constructor(a, b, c, lengthTop, sortNum) {
    super(a, b);
    this.id = c
    this.lengthTop = lengthTop
    this.sortNum = sortNum
  }
}
class Child6 extends addData {
  constructor(a, b, c, numTop, sortNum) {
    super(a, b);
    this.id = c
    this.numTop = numTop
    this.sortNum = sortNum
  }
}
class Child5 extends Child2 {
  constructor(a, b, id, lengthTop, sortNum, list) {
    super(a, b, id, lengthTop, sortNum);
    this.list = list || [new Child6('', 5, '', '', 1), new Child6('', 5, '', '', 2)]
  }
}

export default {
  components: {
    breaDcrumb
  },
  data() {
    return {
      addData: {
        code: ''
      },
      allData: {
        1: [],
        2: [],
        3: [],
        4: [],
        5: []
      },
      list: [],
      companylist: [],
      companyId: '',
    }
  },
  async created() {
    this.companyId = getUserInfo().companyId;
    companyId = getUserInfo().companyId;
    companyName = getUserInfo().companyName;
    this.companylist = await permissionsCompanyList()
  },
  mounted() {
    this.getData0()
    this.getList0()
  },
  methods: {
    changeCompany () {
      companyId = this.companyId;
      companyName = this.companylist.find(item => item.id === this.companyId).name;
      this.getData0()
    },
    async  open(type) {
      loadingInstance = Loading.service();
      if (type == 1) {
        this.allData[type].push(new Child1('', type))
      }
      if (type == 2 || type == 3) {
        this.allData[type].push(new Child2('', type))
      }
      if (type == 5) {
        this.allData[type].push(new Child5('', type))
      }
      let arr = [...this.allData[type]]
      arr.map((res, k) => res.sortNum = k)//区间排序号
      const { code } = await saveOrUpdate(arr)
      if (code == 1001) {
        this.getData0()
      }
    },
    /**获取数据,为区间模块时，需要首次保存优化初始区间模块*/
    async getData0() {
      const { data } = await getData({ companyId: this.companyId });
      this.allData = this.$options.data().allData
      if (loadingInstance) {
        loadingInstance.close();
      }
      console.log(data)
      if (data) {
        if (data['4']) {
          let arr = ['正90度', '负90度', '正45度', '负45度']
          const setarr4 = (item, cur) => {
            let a = data['4'].find(res => (res.name == cur))
            a ? item.push(new Child1(a.difficultyCoefficient, 4, a.name, [], a.id)) : item.push(new Child1('', 4, cur))
            return item
          }
          this.allData['4'] = arr.reduce(setarr4, new Array())
        } else {
          console.log(2);
          let arr = ['正90度', '负90度', '正45度', '负45度']
          const setarr4 = (item, cur) => {
            item.push(new Child1('', 4, cur))
            return item
          }
          this.allData['4'] = arr.reduce(setarr4, new Array())
          console.log(JSON.parse(JSON.stringify(this.allData['4'])))
        }
        if (data['1']) {
          const setarr1 = (item, cur) => {
            cur.showarr = JSON.parse(cur.name || '[]').map(res => (res.id))
            item.push(cur)
            return item
          }
          this.allData['1'] = data['1'].reduce(setarr1, new Array())
          this.allData['1'].forEach((v) => {
            if (v.difficultyCoefficient == null) {
              v.difficultyCoefficient = undefined
            }
          })
        }
        if (data['2'] && data['2'].length !== 0) {
          console.log(JSON.parse(JSON.stringify(data['2'])))
          const setarr2 = (item, cur) => {
            console.log(JSON.parse(JSON.stringify(item)))
            console.log(JSON.parse(JSON.stringify(cur)))
            item.push(new Child2(cur.difficultyCoefficient, 2, cur.id, cur.lengthTop, cur.sortNum))
            return item
          }
          this.allData['2'] = data['2'].reduce(setarr2, new Array())
          this.allData['2'].forEach((v) => {
            if (v.difficultyCoefficient == null) {
              v.difficultyCoefficient = undefined
            }
          })
        } else {
          this.allData['2'].push(new Child2('', 2, '', '', 1))
          this.allData['2'].push(new Child2('', 2, '', '', 2))
          this.change2(2)
        }
        if (data['3'] && data['3'].length !== 0) {
          const setarr2 = (item, cur) => {
            item.push(new Child2(cur.difficultyCoefficient, 3, cur.id, cur.lengthTop, cur.sortNum))
            return item
          }
          this.allData['3'] = data['3'].reduce(setarr2, new Array())
          this.allData['3'].forEach((v) => {
            if (v.difficultyCoefficient == null) {
              v.difficultyCoefficient = undefined
            }
          })
        } else {
          this.allData['3'].push(new Child2('', 3, '', '', 1))
          this.allData['3'].push(new Child2('', 3, '', '', 2))
          this.change2(3)
        }
        if (data['5'] && data['5'].length !== 0) {
          const setarr2 = (item, cur) => {
            item.push(new Child5(cur.difficultyCoefficient, 5, cur.id, cur.lengthTop, cur.sortNum, cur.list))
            return item
          }
          this.allData['5'] = data['5'].reduce(setarr2, new Array())
          console.log(this.allData['5'])
          this.allData['5'].forEach((v) => {
            if (v.difficultyCoefficient == null) {
              v.difficultyCoefficient = undefined
            }
          })
        } else {
          this.allData['5'].push(new Child5('', 5, '', '', 1))
          this.allData['5'].push(new Child5('', 5, '', '', 2))
          this.change2(5)
        }
      } else {
        let arr = ['正90度', '负90度', '正45度', '负45度']
        const setarr4 = (item, cur) => {
          item.push(new Child1('', 4, cur))
          return item
        }
        this.allData['4'] = arr.reduce(setarr4, new Array())
        this.allData['2'].push(new Child2('', 2, '', '', 1))
        this.allData['2'].push(new Child2('', 2, '', '', 2))
        this.change2(2)
        this.allData['3'].push(new Child2('', 3, '', '', 1))
        this.allData['3'].push(new Child2('', 3, '', '', 2))
        this.change2(3)
        this.allData['5'].push(new Child5('', 5, '', '', 1))
        this.allData['5'].push(new Child5('', 5, '', '', 2))
        this.change2(5)
      }
    },
    async getList0() {
      const { data } = await getList({ typeId: 1 })
      this.list = data
    },
    /**保存或更新单条*/
    async change(low) {
      console.log('保存单条')
      let _this = this
      loadingInstance = Loading.service();
      let arr = []
      arr.push(low)
      const { code } = await saveOrUpdate(arr)
      if (code == 1001) {
        _this.getData0()
        console.log(1);
      }
    },
    /**删除*/
    async  delItem1(low, index) {
      let _this = this
      if (!low.id) {
        _this.allData['1'].splice(index, 1)
        return
      }
      loadingInstance = Loading.service();
      let arr = []
      low.status = 0
      arr.push(low)
      const { code } = await saveOrUpdate(arr)
      if (code == 1001) {
        _this.getData0()
        console.log(1);
      }
    },
    /**保存或更新泵送标号*/
    async change1(low, k) {
      setTimeout(async () => {
        if (!low.difficultyCoefficient&&low.difficultyCoefficient!==0) {
          return
        }
        let arr0 = this.allData['1']
        let dataArr = []
        arr0.forEach((v, index) => {
          if (k != index) {
            dataArr = [...dataArr, ...v.showarr]
          }
        })
        for (let i = 0; i < low.showarr.length; i++) {
          if (dataArr.findIndex((res3) => res3 == low.showarr[i]) != -1) {
            this.$message({
              message: '不能选择已存在标号！',
              type: 'warning'
            });
            low.showarr.splice(i, 1)
            return
          }
        }
        let _this = this
        let arr = []
        loadingInstance = Loading.service();
        const setarr = (item, cur) => {
          let a = _this.list.find(res => (res.id == cur))
          item.push({ id: a.id, name: a.name })
          return item
        }
        low.name = JSON.stringify(low.showarr.reduce(setarr, new Array()))
        arr.push(low)
        console.log(JSON.parse(JSON.stringify(this.allData['1'])))
        console.log(JSON.parse(JSON.stringify(arr)))
        const { code } = await saveOrUpdate(arr)
        if (code == 1001) {
          _this.getData0()
          console.log(1);
        }
      }, 100)
    },
    /**保存区间*/
    async  change2(key, valueName) {
      console.log(this.allData[key])
      console.log('保存区间')
      let arr = []
      arr = this.allData[key]
      arr.map((res, k) => res.sortNum = k)//区间排序号
      /**判断区间范围是否正确--开始 */
      let arr1 = arr
      let type1 = false, type2 = false;
      if (valueName == 'lengthTop') {
        arr1.forEach((v, k) => {
          if (k > 0 && (v.lengthTop == '' || arr1[k - 1].lengthTop == '')) {
            type2 = true
          }
          if (k == 0 && arr1.length > 1 && arr1[k + 1].lengthTop - v.lengthTop < 0) {
            type1 = true
          }
          if (k > 0 && k < arr1.length - 1 && v.lengthTop - arr1[k - 1].lengthTop < 0) {
            type1 = true
          }
        })
      } else if (valueName == 'numTop') {
        arr1.forEach((v) => {
          v.list.forEach((v2, k2) => {
            if (k2 > 0 && (v2.numTop == '' || v.list[k2 - 1].numTop == '')) {
              type2 = true
            }
            if (k2 == 0 && v.list.length > 1 && v.list[k2 + 1].numTop - v2.numTop < 0) {
              type1 = true
            }
            if (k2 > 0 && k2 < v.list.length - 1 && v2.numTop - v.list[k2 - 1].numTop < 0) {
              type1 = true
            }
          })
        })
      } else {
        arr1.forEach((v, k) => {
          if (k > 0 && (v.lengthTop == '' || arr1[k - 1].lengthTop == '')) {
            type2 = true
          }
          if (k == 0 && arr1.length > 1 && (arr1[k + 1].lengthTop - v.lengthTop < 0&&arr1[k + 1].lengthTop)) {
            type1 = true
          }
          if (k > 0 && k < arr1.length - 1 && (v.lengthTop - arr1[k - 1].lengthTop < 0&&v.lengthTop)) {
            type1 = true
          }
        })
      }
      if (!type2 && type1) {
        this.$message({
          message: '区间值范围不正确，请检查！',
          type: 'warning'
        });
        return
      }
      loadingInstance = Loading.service();
      /**判断区间范围是否正确--结束 */
      const { code } = await saveOrUpdate(arr)
      if (code == 1001) {
        this.getData0()
      }
    },
    /**删除区间*/
    delitem2(low, index, key) {
      let _this = this
      if (!low.id) {
        _this.allData[key].splice(index, 1)
        return
      }
      loadingInstance = Loading.service();
      let arr = []
      low.status = 0
      _this.allData[key].splice(index, 1)
      _this.$nextTick(async () => {
        arr = [..._this.allData[key]]
        arr.push(low)
        const { code } = await saveOrUpdate(arr)
        if (code == 1001) {
          _this.getData0()
          console.log(1);
        }
      })
    },
    /**添加区间1*/
    addItem6(low) {
      low.list.push(new Child5('', 5, '', ''))
      this.change2(5)
    },
    /**删除区间1*/
    delitem6(item, index, low) {
      if (!item.id) {
        low.list.splice(index, 1)
        return
      }
      loadingInstance = Loading.service();
      item.status = 0
      low.list.splice(index, 1)
      this.$nextTick(async () => {
        let arra = low.list
        arra.push(item)
        const { code } = await saveOrUpdate(arra)
        if (code == 1001) {
          this.getData0()
          console.log(1);
        }
      })

    }
  },
}
</script>


<style lang="scss" scoped>
.el-input,
.el-select,
.el-textarea {
  width: 240px;
}
.divdiv {
  height: 52px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.divdiv + .divdiv {
  border-top: 1px solid #dcdfe6;
}
.itemdiv {
  display: flex;
  justify-content: center;
  align-items: center;
}
.itemdiv1 {
  display: flex;
  justify-content: center;
  align-items: center;
  p {
    padding: 0 10px;
  }
}
.info {
  width: 90%;
  max-width: 1440px;
  margin: 20px auto;
  > div + div {
    padding-top: 20px;
  }
}
.title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
<style>
.PMDM .el-input--small .el-input__inner {
  text-align: center;
}
</style>

